package qt.service.impl;

import ht.dao.GldwDao;
import ht.dao.XzqhxxDao;
import ht.domain.Gldw;
import ht.domain.Xzqhxx;
import org.springframework.stereotype.Service;
import qt.domain.TreeChild;
import qt.domain.TreeParent;
import qt.service.QTIndexService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by yanlin on 2017/10/21.
 */
@Service
public class QTIndexServiceImpl implements QTIndexService{
    @Resource(name = "xzqhxxDao")
    private XzqhxxDao xzqhxxDao;

    @Resource(name = "gldwDao")
    private GldwDao gldwDao;

    public List<TreeChild> getXzqhxxTree(){
         List<Xzqhxx> xzqhList = xzqhxxDao.getChildXzqhxx("00");
         List<TreeChild> tcList = new ArrayList<TreeChild>();
         for(Xzqhxx list : xzqhList){
            TreeChild tc = new TreeChild();
            tc.setId(list.getAddvcd());
            tc.setText(list.getAddvnm());
            tcList.add(tc);
         }
         return tcList;
    }

    public List<TreeChild> getGldwTree(){
        List<Gldw> xzqhList = gldwDao.getAllGldw();
        List<TreeChild> tcList = new ArrayList<TreeChild>();
        for(Gldw list : xzqhList){
            TreeChild tc = new TreeChild();
            tc.setId("g" + list.getAdmagcd());
            tc.setText(list.getAdmag());
            tcList.add(tc);
        }
        return tcList;
    }

    public String getXzqhName(String id){
        return xzqhxxDao.getAddvnmById(id);
    }

    public String getGldwName(String stcd){
        return gldwDao.getGldwName(stcd);
    }
}
